package com.yanggu.flink.datastream_api.source

import com.yanggu.flink.datastream_api.pojo.SensorReading
import org.apache.flink.streaming.api.scala._

/**
 * 从集合中创建Source
 * fromCollection、fromElements、fromSequences
 */
object SourceFromList {

  def main(args: Array[String]): Unit = {
    val env = StreamExecutionEnvironment.getExecutionEnvironment
    val stream = env.fromCollection(List(
      SensorReading("sensor_1", System.currentTimeMillis(), 35.8),
      SensorReading("sensor_2", System.currentTimeMillis(), 45.8),
      SensorReading("sensor_3", System.currentTimeMillis(), 65.8)
    ))

    stream.print("stream1: ").setParallelism(1)

    env.execute()
  }

}
